/*
 * @Author: lixiang
 * @Date: 2020-05-24 01:01:18
 * @LastEditTime: 2020-08-12 19:44:00
 * @LastEditors: Please set LastEditors
 * @Description:
 * @FilePath: /wxapp_doctor/src/scripts/utils/util.js
 * @可以输入预定的版权声明、个性签名、空行等
 */

const formatTime = date => {
  const year = date.getFullYear();
  const month = date.getMonth() + 1;
  const day = date.getDate();
  // const hour = date.getHours();
  // const minute = date.getMinutes();
  // const second = date.getSeconds();

  return [year, month, day].map(formatNumber).join("");
  // + ' ' + [hour, minute, second].map(formatNumber).join(':')
};

const formatNumber = n => {
  n = n.toString();
  return n[1] ? n : "0" + n;
};

module.exports = {
  formatTime: formatTime
};
